package com.yunhe.authority.repository.authority;

import com.yunhe.authority.domain.authority.FirmStaticData;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @ClassName FirmStaticDataRepository
 * @Description 单位静态数据仓库
 * @Author HeTao
 * @Date 2020/11/2 14:44
 * @Version 1.0
 **/
@Repository
public interface FirmStaticDataRepository extends Neo4jRepository<FirmStaticData, Long> {

    @Query("match(f:Firm)-[r:FirmStaticData_OF]->(fsd:FirmStaticData) where ID(f)={firmId} return fsd")
    FirmStaticData findByFirmId(@Param("firmId") Long firmId);


    /**
     * 查询已经绑定静态数据的单位
     * @param firmId
     * @return
     */
    @Query("match(f:Firm)-[r:FirmStaticData_OF]->(fsd:FirmStaticData) where ID(f)={firmId}  return ID(fsd) as id ")
    Long findBindStaticDataFirmByFrimId(@Param("firmId") Long firmId);
}
